﻿Imports System.Data.OleDb
Public Class Comments
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim conn = New OleDbConnection(ConfigurationManager.ConnectionStrings("MovieConnectionString").ToString())
        Dim Topic As String = Request.QueryString("ID").ToString()
        Dim str = " SELECT [UserName],[Topics], [Description] FROM [sbwithName] WHERE Topics= '" + Topic + "' "
        Dim cmd1 As OleDb.OleDbCommand = New OleDb.OleDbCommand(str, conn)
        conn.Open()
        Dim reader As OleDb.OleDbDataReader = cmd1.ExecuteReader()
        While reader.Read()
            lbl_username.Text = reader.Item(0).ToString()
            lbl_Topic.Text = reader.Item(1).ToString()
            lbl_Description.Text = reader.Item(2).ToString()

        End While

        reader.Close()
        cmd1.Dispose()

        'Repeater1.DataSource = SqlDataSource_Comment
        'Repeater1.DataBind()

    End Sub

    Protected Sub btnComment_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnComment.Click
        Dim Topic = Request.QueryString("ID")
        Dim Conn As New OleDbConnection(ConfigurationManager.ConnectionStrings("MovieConnectionString").ToString())
        Conn.Open()
        Dim sql As String = "INSERT INTO SBComments (Author,comment,Topics) VALUES(@Author,@comment,@Topics)"
        Dim cmd As New OleDbCommand(sql, Conn)
        cmd.Parameters.AddWithValue("@Author", User.Identity.Name)
        cmd.Parameters.AddWithValue("@comment", txtb_comment.Text)
        cmd.Parameters.AddWithValue("@Topics", Topic)
        cmd.ExecuteNonQuery()
        Conn.Close()

        Repeater1.DataBind()
        txtb_comment.Text = ""
    End Sub
End Class